<?php
/**
 * 任务计划管理
 * ============================================================================

 * ============================================================================
 */
defined('BY_JYA') or exit('error');
$setting=uni_setting('member_setting');
$sign=$setting['sign'];
if(!$sign['open_getfee'] || $sign['getfee_rate']<=0){
	exit('success');
}
$week=date('w',time());
if($sign['open_week67'] && ($week==0 || $week==6)){
	exit('success');
}
$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
$isplan = pdo_get('core_credit_log',array('plugin'=>'jy_sign','tag'=>'isplan','createtime >'=>$daytime),array('id','fee'));
if($isplan){
	exit('success');
}
$params=array('credit1 >'=>0,'onemid'=>0,'is_virtual'=>0);
$members = pdo_getall('core_members',$params,array('id','credit1'));
if($members){
	foreach($members as $item){
		$fee=$sign['getfee_rate']*$item['credit1']/100;
		if($fee > 0){
			model('core/member')->member_credit($item['id'],'credit2',$fee,true,'jy_sign','每日积分产生余额','isplan');
			model('core/member')->member_credit($item['id'],'credit1',$fee,false,'jy_sign','每日释放积分为余额','isplan');	
		}	
	}
}
exit('success');